package com.spica.platform.watermark.exception;

import com.spica.platform.base.exception.errorcode.IErrorCode;
import com.spica.platform.common.utils.StringUtil;

import java.util.Arrays;

public enum WatermarkErrorCodEnum implements IErrorCode {
    UN_KNOWN_WATERMARK_ERROR("BASE_WATERMARK_00000", "未知系统异常"),
    WATERMARK_ADD_TO_DOCX_ERROR("BASE_WATERMARK_00001","Description Failed to add watermark to docx"),
    WATERMARK_ADD_TO_IMAGE_ERROR("BASE_WATERMARK_00002", "Failed to add watermark to the image"),
    WATERMARK_ADD_TO_PDF_ERROR("BASE_WATERMARK_00003", "Description Failed to add watermark to PDF"),
    WATERMARK_ADD_TO_PPT_ERROR("BASE_WATERMARK_00004", "Description Failed to add watermark to ppt"),
    WATERMARK_ADD_TO_EXCEL_ERROR("BASE_WATERMARK_00005", "Description Failed to add watermark to EXCEL"),
    ;
    private String rtnCod;
    private String rtnMsg;

    WatermarkErrorCodEnum(String rtnCod, String rtnMsg) {
        this.rtnCod = rtnCod;
        this.rtnMsg = rtnMsg;
    };
    @Override
    public String getRtnMessage() {
        return rtnMsg;
    }

    @Override
    public String getRtnCode() {
        return rtnCod;
    }

    @Override
    public IErrorCode getInstanceByErrorCode(String rtnCod) {
        return Arrays.stream(WatermarkErrorCodEnum.values())
                .filter(watermarkErrorCodEnum -> StringUtil.equals(watermarkErrorCodEnum.rtnCod, rtnCod))
                .findFirst().orElse(WatermarkErrorCodEnum.UN_KNOWN_WATERMARK_ERROR);
    }
}
